import { createStore } from "vuex";

//全局变量【专门接受本地存储的数据】
let defaultCity = '广州';
//在localStorage对象中初始化一个属性city的值
if( localStorage.city ){
	//有值的
	defaultCity = localStorage.city;
}

export default createStore({
  state: {
	 title:'全球经典',
	 on_show:true,
	 num:0,
	 //初始化一个变量：存储被选中的城市名
	 cityName:defaultCity,
  },
  mutations: {
	  setshow(state){
		state.on_show=false
	  },
	  NumSum(state){
	  	state.num+=5
	  },
	  getcity(state,city){
	  		 //传新的城市过来的时候，直接将其传入本地
	  		 localStorage.city=city,
	  		 state.cityName=city
	  },
	  gettitle(state,val){
		  state.title=val
	  }
  },
  getters:{},
  actions: {},
  modules: {},
});
